﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp2
{
    class DbHelper
    {
        private static readonly  string conString = "server=.;database=Admin3000;uid=sa;pwd=azhana824;";
        ///<summary>
        ///获得表数据
        ///</summary> 
        ///<param name="sql">select语句</param>
        ///<returns>表数据</returns>
           public static DataTable GetDataTable(string sql)
        {         

            SqlConnection sqlConnection = new SqlConnection(conString);
          

            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql,sqlConnection);

            DataTable dt = new DataTable();
            sqlConnection.Open();

            dataAdapter.Fill(dt);

            return dt;
        }
    }
}
